package com.jetlion.queue.queuelinked;
public class LinkedListQueue {
    public QueueNode front;
    public QueueNode rear;
    public LinkedListQueue() {
        front = null;
        rear = null;
    }
    public Boolean enqueue(int value) {
        QueueNode node = new QueueNode(value);
        if (rear == null) {
            front = node;
        } else {
            rear.next = node;
        }
        rear = node;
        return true;
    }
    public int dequeue() {
        int value;
        if (!(front == null)) {
            if (front == rear) {
                rear = null;
            }
            value = front.data;
            front = front.next;
            return value;
        } else {
            return -1;
        }
    }
}
